package controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import pojo.AddressBookOnline;
import service.Impl.AddressBookOnlineService;

import java.util.List;
@Controller
@RequestMapping("/contact")
public class AddressBookOnlineController {

    @Autowired
    private AddressBookOnlineService addressBookOnlineService;

    @RequestMapping(value = "/list")
    public String list(Model model){
        List<AddressBookOnline> list = addressBookOnlineService.list();
        model.addAttribute("list",list);
        return "list";
    }
    @RequestMapping(value = "/querid")
    public String querid(Integer id, Model model){
        AddressBookOnline addressBookOnline = addressBookOnlineService.querid(id);
        model.addAttribute("addressBookOnline",addressBookOnline);
        return "list";
    }
    @PostMapping(value = "/add")
    public String add(AddressBookOnline addressBookOnline,Model model){
        boolean addressBookOnline1 = addressBookOnlineService.add(addressBookOnline);
        model.addAttribute("addressBookOnline",addressBookOnline);
        return "add";
    }
}
